<?php
namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Examplesapi extends Model
{
    protected $table ='examples';
    public $timestamps = false;
    protected $guarded = [
        'title', 'img', 'redirect_url', 'sort', 'on_line_time', 'off_line_time', 'created_at', 'updated_at'
    ];

    public function getData(){
        $examplesList = array();
        $sql = \DB::table($this->table)
            ->whereNull('deleted_at');

        $examplesList['list'] = $sql->select('id','description','backgroundImage','area','view')->orderBy('created_at', 'desc')

            ->get();

        return $examplesList;
    }

    //装修案例详情接口
    public function getDatalist($id=[]){
        $examplesList = array();
        $sql = \DB::table($this->table.' as p')
            ->select('m.img','p.view')
            ->leftjoin('example_img as m' , 'm.example_id' , '=' , 'p.user_id')
            ->whereNull('p.deleted_at')
            ->where('p.user_id',$id);

        $examplesList['list'] = $sql
            ->orderBy('p.created_at', 'desc')

            ->get();

        return $examplesList;
    }




}